import types from "@/store/mutation-types";

import {getNoticeApi} from '@/services/api/global';

const notice = {
  state: {
    transfer: 0,
    withdraw: 0,
    recharge: 0,
    levelList:[],
  },

  mutations: {
    [types.GET_NOTICE] (state, data) {
      state.transfer = data.transfer
      state.withdraw = data.withdraw
      state.recharge = data.recharge
    }
  },

  actions: {
    async [types.GET_NOTICE] ({commit, dispatch}) {
      getNoticeApi().then(([result, data]) => {
        commit(types.GET_NOTICE, data)
      })
      setTimeout(() => dispatch(types.GET_NOTICE), 15000)
    }
  }
}

export default notice
